/******************渲染数据**************/
 var cid=GetQueryString('cid')
 var aid=GetQueryString('aid')
 var type=GetQueryString('type')
switch (type){
	case 'psyer':
	    getPsyDetail()
		break;
    case 'protector':
        getProDetail()
        break;
	default:
	    getDoDetail()
		break;
}
    
/******************渲染数据end**************/


/******************跳转**************/
$(document).ready(function(){
    mui(".mui-content").on('tap','.addResult',function(){
        mui.openWindow({
            url:`addResult.html?aid=${aid}&&type=${type}`,
            id:'addResult.html',
        });
    })
    mui(".mui-content").on('tap','.casexx',function(){
        mui.openWindow({
            url:`casexx.html?aid=${aid}&&type=${type}`,
            id:'casexx.html',
        });
    })
})
/******************跳转end**************/

//普通获取详情
 function getDoDetail(){
     var getDoDetailData={
        title:"后台获取代办详情",
        url:"schedule_manage/replyDetail",
        fromwho:'ld',
        sendData:{
           apply_id:aid
        }
    };
    //获取数据
    getAjax(getDoDetailData,
        function(data){
            if(data.result==1){
                var curData=data.data
                var scheduleOne=JSON.stringify(curData)
                localStorage.setItem('scheduleOne',scheduleOne)
                if(data.data.apply.letter&&data.data.apply.letter_file){
                    var letter=decodeHtml(data.data.apply.letter_file)
                    var letterJson=JSON.parse(data.data.apply.letter)
                    var html = template.render(letter,letterJson);
                    $('#htwjInfo').html(html)
                }else{
                    $('#htwjInfo').html('<p>暂无函件</p>')
                }
            }
        },
        function(data){
            console.log(data.msg)
        }
    )
 }
 //心理咨询获取详情
 function getPsyDetail(){
     var getDoDetailData={
        url:"Psy_Record_Manage/getRecordList",
        fromwho:'ld',
        sendData:{
           id:aid
        }
    };
    //获取数据
    getAjax(getDoDetailData,
        function(data){
            if(data.result==1){
                var curData=data.data
                var scheduleOne=JSON.stringify(curData)
                localStorage.setItem('scheduleOne',scheduleOne)
                if(data.data.appoint.letter&&data.data.appoint.letter_file){
                    var letter=decodeHtml(data.data.appoint.letter_file)
                    var letterJson=JSON.parse(data.data.appoint.letter)
                    var html = template.render(letter,letterJson);
                    $('#htwjInfo').html(html)
                }else{
                    $('#htwjInfo').html('<p>暂无函件</p>')
                }
            }
        },
        function(data){
            console.log(data.msg)
        }
    )
 }
 //观护帮教详情
 function getProDetail(){
     var getDoDetailData={
        url:"Guard_Record_Manage/recordList",
        fromwho:'ld',
        sendData:{
           id:aid,
           base_msg_id:cid
        }
    };
    //获取数据
    getAjax(getDoDetailData,
        function(data){
            if(data.result==1){
                var curData=data.data
                $('#htwjInfo').html('<p>暂无函件</p>')
                var scheduleOne=JSON.stringify(curData)
                localStorage.setItem('scheduleOne',scheduleOne)
            }
        },
        function(data){
            console.log(data.msg)
        }
    )
 }
